home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / findwi.zip / FINDWIN.PAS < prev    next >
Pascal/Delphi Source File  |  1991-02-09  |  4KB  |  135 lines

  1. {$F+,R-,S-,V-}
  2.  
  3. PROGRAM FINDWIN;
  4.  
  5. {$M 1024,0,0}
  6.  
  7. {   Copyright (C) 1991 by: NativSoft Computing
  8.                            1155 College Ave.
  9.                            Adrian, MI, 49221
  10.                            (517) 265-6080
  11.                            CIS 71160,1045
  12.  
  13.  
  14.     A quick and dirty program to detect and report whether any version
  15.     of Microsoft Windows (tm) is running.
  16.  
  17.     Based on information published in an article
  18.     by Ben Myers of Spirit of Performance, Inc.
  19.     (Dr. Dobb's Journal, #172, January, 1991, pg 116)
  20.  
  21.     ALTINTR was adapted from a public domain procedure
  22.     found in INFOPLUS by ANDREW ROSSMAN.  This procedure
  23.     is necessary because TP only FAKES an INT!!  The normal
  24.     TP construct, INTR($2F,regs), therefore fails to detect
  25.     Windows running in enhanced mode.  With TP6's BASM the required
  26.     code can be inserted directly into the body of the program.
  27.  
  28.     Compile with Turbo Pascal v5.5 (requires REALINT.OBJ) or
  29.     Turbo Pascal v6 (requires conditional define "ver6")
  30.  
  31.     This program is released to the public domain and is provided
  32.     "as is" without any warranty of any kind, either expressed or
  33.     implied, including, but not limited to, the implied warranties
  34.     or merchantability and fitness for a particular reason.  The 
  35.     entire risk as to the quality and performance of the program 
  36.     is with the user.
  37.  
  38. }
  39.  
  40. uses dos,crt;
  41.  
  42. {$IFNDEF ver6}
  43. {$L REALINT}
  44. PROCEDURE ALTINTR(a:byte;b:registers); external;
  45. {$ENDIF}
  46.  
  47. var
  48.     quiet : boolean;
  49.     t     : byte;
  50.     x     : word;
  51.     {$IFNDEF ver6}
  52.     regs  : registers;
  53.     {$ENDIF}
  54.  
  55. BEGIN
  56.   checkbreak := false;
  57.   if paramstr(1) = '?' then
  58.    begin
  59.      clrscr;
  60.      writeln('FINDWIN  ***  Copyright (C) 1991 by NativSoft Computing');
  61.      writeln;
  62.      writeln('This program returns:');
  63.      writeln('Errorlevel = 0  No WIN version detected');
  64.      writeln('           = 1  WIN 3.x enhanced');
  65.      writeln('           = 2  WIN/386 or WIN 2.xx');
  66.      writeln('           = 3  WIN 3.x real or standard');
  67.      writeln;
  68.      writeln('/Q (quiet) switch suppresses all messages normally written to');
  69.      writeln('the screen, but still returns ERRORLEVELS for use in batch files');
  70.      writeln;
  71.      halt;
  72.    end;
  73.   quiet := ( (paramstr(1) = '/q') or (paramstr(1) = '/Q') );
  74.  
  75.   {$IFNDEF ver6}
  76.   fillchar(regs,sizeof(regs),0);
  77.   regs.ax := $1600;
  78.   altintr($2F,regs);
  79.   x := regs.al;
  80.   {$ELSE}
  81.   ASM
  82.     MOV AX, 1600h
  83.     INT 2Fh
  84.     MOV x, AX
  85.   END;
  86.   x := lo(x);
  87.   {$ENDIF}
  88.  
  89.  
  90.   case x of
  91.     $01,$FF : t := 2;           {win/386, ver 2.xx running}
  92.     $00,$80 : begin             {Enhanced, WIN/386, or WIN ver 2.xx NOT RUNNING
  93.                                  ... so, test for real or standard win 3.x }
  94.  
  95.                 {$IFNDEF ver6}
  96.                 fillchar(regs,sizeof(regs),0);
  97.                 regs.ax := $4680;
  98.                 altintr($2F,regs);
  99.                 x := regs.ax;
  100.                 {$ELSE}
  101.                 ASM
  102.                   MOV AX, 4680h
  103.                   INT 2Fh
  104.                   MOV x, AX
  105.                 END;
  106.                 {$ENDIF}
  107.  
  108.  
  109.                 if x = 0 then t := 3   {real or standard win 3.x running}
  110.                 else t := 0;              {apparently NO WIN is running}
  111.               end;
  112.     else t := 1;  {enhanced win 3.x running}
  113.   end; {case}
  114.  
  115.  
  116. if not quiet then
  117.  begin
  118.    clrscr;
  119.    writeln('FINDWIN  ***  Copyright (C) 1991 by NativSoft Computing');
  120.    writeln;
  121.    case t of
  122.      0 : writeln('No version of Windows was detected');
  123.      1 : writeln('Windows 3 is running in enhanced mode');
  124.      2 : writeln('Windows/386 or Windows 2.x is running');
  125.      3 : writeln('Windows 3 is running in standard or real mode');
  126.    end; {case}
  127.    writeln;
  128.    write('Press <ENTER> to continue...');
  129.    readln;
  130.    clrscr;
  131.  end;
  132.  
  133. halt(t);
  134.  
  135. end.